﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web.Http;
using EvertonApp.Data.UnitOfWork;
using EvertonApp.Transporte;

namespace EvertonApp.WebAPI.Controllers
{
    public class ComentarioController : ApiController
    {

        private ForoUoW _foro;

        public ComentarioController()
        {
            this._foro = new ForoUoW();
        }

        // GET api/comentario
        public IEnumerable<Comentario> Get()
        {
            IQueryable<Comentario> comentarios = _foro.ComentariosRepository.GetAll();

            return comentarios.AsEnumerable();
        }

        // GET api/comentario/5
        public Comentario Get(Guid id)
        {
            return _foro.ComentariosRepository.GetById(id);
        }

        // POST api/comentario
        public Comentario Post([FromBody]Comentario value)
        {
            return _foro.ComentariosRepository.Insert(value);
        }

        // PUT api/comentario/5
        public bool Put(Guid id, [FromBody]Comentario value)
        {
            return _foro.ComentariosRepository.Update(id, value);
        }

        // DELETE api/comentario/5
        public bool Delete(Guid id)
        {
           return _foro.ComentariosRepository.Delete(_foro.ComentariosRepository.GetById(id));
        }
    }
}
